package com.yunao.commons.serachcore.core.query;

import com.yunao.commons.serachcore.core.help.*;

import java.util.Arrays;

class QueryImpl implements Query {

	private static final long serialVersionUID = 1L;

	private Mode mode;

	private Sort sort; // date, date_ace, rela, random, views, comments, likes
	private String keywords;
	private String title;

	private GroupField group; // 分组字段，hour（按小时分组）、day（按天分组）、week（按周分组）、author、domain、host、media_type、channel、emotion、author_type、location、domain_level

	private GroupField group2; // 分组字段，author、domain、host、media_type、channel、emotion、author_type、location、domain_level

	private int maxWord;
	private int maxGroup;
	private double distance;
	private String miningField;

	private long[] ids;

	private long[] between; // between $time1 end $time2
	private long greaterThan; // greater than $time
	private long greaterEqual; // greater than or equal to $time

	private int offset;
	private int limit;

	private String[] author;
	private String[] domain;
	private String[] host;
	private String[] url;
	private String[] source;
	private String[] newsSource;

	private String[] mediaType; // 媒体类型，新闻、政务、客户端、电子报、贴吧、论坛、微博、微信、博客、视频、电视、网站
	private String[] messageType; // 信息类型，一般新闻、新闻评论、主题帖、回帖、博文、微博正文、微信正文
	private String[] channel; // 频道分类，社会综合、能源环保、财经金融,健康医疗、地产家居、时尚娱乐、体育艺术、科技互联网、教育人力、旅游生活、军事时政、汽车交通、广告传媒
	private String[] emotion; // 正负面，正面、负面、中性
	// private String[] authorType; // 作者分类，新注册、偶尔发帖、机器人、意见领袖、一般参与者、活跃分子
	private String[] domainLevel; // 网站级别，中央重点、中央行业、省级重点、地方城市、商业重点、商业行业、境内其它、境外新闻、境外其它
	private String[] location;

	private String[] stopWords;

	private int domestic; // 是否境内，过滤类型，0：全部、1：境内、2：境外

	private String[] nr;
	private String[] ns;
	private String[] nt;

	private boolean trimArticle; // 返回值中content字段开关。0：返回content字段，1：不返回content字段，默认为0

	@Override
	public Mode getMode() {
		return mode;
	}

	void setMode(Mode mode) {
		this.mode = mode;
	}

	@Override
	public Sort getSort() {
		return sort;
	}

	void setSort(Sort sort) {
		this.sort = sort;
	}

	@Override
	public String getKeywords() {
		return keywords;
	}

	void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	@Override
	public String getTitle() {
		return title;
	}

	void setTitle(String title) {
		this.title = title;
	}

	@Override
	public GroupField getGroup() {
		return group;
	}
	
	void setGroup(GroupField group) {
		this.group = group;
	}

	@Override
	public GroupField getGroup2() {
		return group2;
	}

	void setGroup2(GroupField group2) {
		this.group2 = group2;
	}

	@Override
	public int getMaxWord() {
		return maxWord;
	}

	void setMaxWord(int maxWord) {
		this.maxWord = maxWord;
	}

	@Override
	public int getMaxGroup() {
		return maxGroup;
	}

	void setMaxGroup(int maxGroup) {
		this.maxGroup = maxGroup;
	}

	@Override
	public double getDistance() {
		return distance;
	}

	void setDistance(double distance) {
		this.distance = distance;
	}

	@Override
	public String getMiningField() {
		if (miningField == null || miningField.isEmpty()) {
			return "TX";
		}
		return miningField;
	}

	void setMiningField(String miningField) {
		this.miningField = miningField;
	}

	@Override
	public long[] getIds() {
		return ids;
	}

	void setIds(long[] ids) {
		this.ids = ids;
	}

	@Override
	public long[] getBetween() {
		return between;
	}

	void setBetween(long[] between) {
		this.between = between;
	}

	@Override
	public long getGreaterThan() {
		return greaterThan;
	}

	void setGreaterThan(long greaterThan) {
		this.greaterThan = greaterThan;
	}

	@Override
	public long getGreaterEqual() {
		return greaterEqual;
	}

	void setGreaterEqual(long greaterEqual) {
		this.greaterEqual = greaterEqual;
	}

	@Override
	public int getOffset() {
		return offset;
	}

	void setOffset(int offset) {
		this.offset = offset;
	}

	@Override
	public int getLimit() {
		return limit;
	}

	void setLimit(int limit) {
		this.limit = limit;
	}

	@Override
	public String[] getAuthor() {
		return author;
	}

	void setAuthor(String[] author) {
		this.author = author;
	}

	public String[] getNewsSource() {
		return newsSource;
	}

	void setNewsSource(String[] newsSource) {
		this.newsSource = newsSource;
	}

	@Override
	public String[] getDomain() {
		return domain;
	}

	void setDomain(String[] domain) {
		this.domain = domain;
	}

	@Override
	public String[] getHost() {
		return host;
	}

	void setHost(String[] host) {
		this.host = host;
	}

	@Override
	public String[] getUrl() {
		return url;
	}

	void setUrl(String[] url) {
		this.url = url;
	}

	@Override
	public String[] getSource() {
		return source;
	}

	void setSource(String[] source) {
		this.source = source;
	}

	@Override
	public String[] getMediaType() {
		return mediaType;
	}

	void setMediaType(String[] mediaType) {
		this.mediaType = mediaType;
	}

	void setMediaType(MediaType[] mediaType) {
		this.mediaType = Arrays.stream(mediaType).map(MediaType::toString)
				.distinct().toArray(String[]::new);
	}

	@Override
	public String[] getMessageType() {
		return messageType;
	}

	void setMessageType(String[] messageType) {
		this.messageType = messageType;
	}

	void setMessageType(MessageType[] messageType) {
		this.messageType = Arrays.stream(messageType).map(MessageType::toString)
				.distinct().toArray(String[]::new);
	}

	@Override
	public String[] getChannel() {
		return channel;
	}

	void setChannel(String[] channel) {
		this.channel = channel;
	}

	void setChannel(Channel[] channel) {
		this.channel = Arrays.stream(channel).map(Channel::toString)
				.distinct().toArray(String[]::new);
	}

	@Override
	public String[] getEmotion() {
		return emotion;
	}

	void setEmotion(String[] emotion) {
		this.emotion = emotion;
	}

	void setEmotion(Emotion[] emotion) {
		this.emotion = Arrays.stream(emotion).map(Emotion::toString)
				.distinct().toArray(String[]::new);
	}

	@Override
	public String[] getDomainLevel() {
		return domainLevel;
	}

	void setDomainLevel(String[] domainLevel) {
		this.domainLevel = domainLevel;
	}

	void setDomainLevel(DomainLevel[] domainLevel) {
		this.domainLevel = Arrays.stream(domainLevel).map(DomainLevel::toString)
				.distinct().toArray(String[]::new);
	}

	@Override
	public String[] getLocation() {
		return location;
	}

	void setLocation(String[] location) {
		this.location = location;
	}

	@Override
	public String[] getStopWords() {
		return stopWords;
	}

	void setStopWords(String[] stopWords) {
		this.stopWords = stopWords;
	}

	@Override
	public int getDomestic() {
		return domestic;
	}

	void setDomestic(int domestic) {
		this.domestic = domestic;
	}

	@Override
	public String[] getNr() {
		return nr;
	}

	void setNr(String[] nr) {
		this.nr = nr;
	}

	@Override
	public String[] getNs() {
		return ns;
	}

	void setNs(String[] ns) {
		this.ns = ns;
	}

	@Override
	public String[] getNt() {
		return nt;
	}

	void setNt(String[] nt) {
		this.nt = nt;
	}

	@Override
	public boolean isTrimArticle() {
		return trimArticle;
	}

	void setTrimArticle(boolean trimArticle) {
		this.trimArticle = trimArticle;
	}

}
